package com.chinaoly.sdk.base;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

/**
 * BaseCustomView
 */
public abstract class BaseCustomView<Binding extends ViewDataBinding> extends FrameLayout {
    protected Binding mBinding;

    public BaseCustomView(@NonNull Context context) {
        this(context, null);
    }

    public BaseCustomView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initAttr(context,attrs);
        init();
    }

    @CallSuper
    protected void init() {
        mBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), getLayoutId(), this, true);
    }

    protected abstract int getLayoutId();
    protected void initAttr(Context context, AttributeSet attrs) {

    }

}
